﻿using System.Collections.Generic;
using System.Linq;
using Atha.Contracts;

namespace Atha.Extensions
{
	namespace TestRunTestResults
	{
		public static class TestRunResultTestExtensions
		{
			public static bool AllSucceeded(this IEnumerable<ITestRunTestResult> testRunTestResults)
			{
				return testRunTestResults.All(test => test.Succeeded());
			}

			public static bool AllFailed(this IEnumerable<ITestRunTestResult> testRunTestResults)
			{
				return testRunTestResults.All(test => test.Failed());
			}

			public static bool HasError(this IEnumerable<ITestRunTestResult> testRunTestResults)
			{
				return testRunTestResults.Any(test => test.IsError());
			}

			public static bool Succeeded(this ITestRunTestResult testRunTestResult)
			{
				return testRunTestResult.Is(Athacore.BuiltIn.TestStatus.Succeeded);
			}

			public static bool Failed(this ITestRunTestResult testRunTestResult)
			{
				return testRunTestResult.Has(Athacore.BuiltIn.TestStatus.Failed);
			}

			public static bool IsError(this ITestRunTestResult testRunTestResult)
			{
				return testRunTestResult.Has(Athacore.BuiltIn.TestStatus.Error);
			}
		}
	}
}